package com.mz.ozy.activity.me;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;

import com.mz.ozy.R;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.bean.MeBean;
import com.mz.ozy.bean.MsgBean;
import com.mz.ozy.bean.MsgDetailBean;
import com.mz.ozy.bean.OrderMsgBean;
import com.mz.ozy.bean.UnreadMsgBean;
import com.mz.ozy.mvp.presenter.MsgPresenter;
import com.mz.ozy.mvp.view.MsgContract;
import com.mz.ozy.utils.Utils;

import org.json.JSONObject;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ServiceAgmentActivity extends BaseActivity<MsgContract.View, MsgPresenter> implements MsgContract.View {

    public static void go(Context context, String id) {
        Intent intent = new Intent(context, ServiceAgmentActivity.class);
        intent.putExtra("id", id);
        context.startActivity(intent);
    }

    @BindView(R.id.webview)
    WebView mWebview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service_agment);
        ButterKnife.bind(this);
        initTitle();
        final String id = getIntent().getStringExtra("id");
        if ("1".equals(id)) {
            tvCenterTitle.setText(R.string.service_agreement);
        } else if ("2".equals(id)) {
            tvCenterTitle.setText(R.string.privite_agreement);
        } else {
            tvCenterTitle.setText(R.string.law_declare);
        }
        tvTitle.setVisibility(View.GONE);
        mPresenter.getAgmentDetail(this, id);
    }

    @Override
    public void getMsgrListSuccess(MsgBean bean) {
    }

    @Override
    public void getOrderMsgrListSuccess(OrderMsgBean bean) {

    }

    @Override
    public void getUnreadMsgSuccess(UnreadMsgBean bean) {

    }

    @Override
    public void getMsgDetailSuccess(MsgDetailBean jsonObject) {
    }

    @Override
    public void getAgmentDetailSuccess(JSONObject jsonObject) {
        JSONObject map = jsonObject.optJSONObject("map");
        if (map != null) {
            try {
                mWebview.loadDataWithBaseURL(null, Utils.getNewContent(map.optString("content")), "text/html", "utf-8", null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void getgetMeInfoSuccess(MeBean bean) {

    }
}
